home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks95 / IsNative.sit / Is Native / MyDrawString.c < prev    next >
Text File  |  1995-06-24  |  2KB  |  96 lines

  1. //
  2. // File:    MyDrawString.c
  3. // Project:    IsNative.π
  4. // Author:    Glenn L. Austin
  5. //            Symantec Corporation
  6. //
  7. #include <Traps.h>
  8. #include "IsNative.h"
  9.  
  10. extern Str255        sysSoftStr;
  11. extern WindowPtr    aboutWindow;
  12. extern void*        oldHideWindowTrap;
  13.  
  14. extern pascal void MyHideWindow(WindowPtr theWindow);
  15.  
  16. pascal void MyDrawString(StringPtr sp)
  17. {
  18.     long        oldA4 = SetA4World();
  19.     WindowPeek    aWind;
  20.     Boolean        resetFace = false;
  21.     Style        oldFace;
  22.     
  23.     if (EqualString(LMGetCurApName(), LMGetFinderName(), false, true))
  24.     {        // current application is the finder!        
  25.         GetPort((GrafPtr*) &aWind);    // get the current port (hopefully it's a window)
  26.         
  27.         if ((375 < aWind->port.portRect.right) &&
  28.                 (aWind->port.portRect.right < 380))        // should be 377 for About…
  29.         {
  30.             if (!aboutWindow)
  31.             {
  32.                 aboutWindow = (WindowPtr) aWind;
  33.                 oldHideWindowTrap = (void*) GetToolTrapAddress(_HideWindow);
  34.                 SetToolTrapAddress((void*) MyHideWindow, _HideWindow);
  35.                 StartAnimation();
  36.             }
  37.             
  38.             if ((aWind->port.pnLoc.v > 83) && (aWind->port.pnLoc.h == 41))
  39.             {
  40.                 // OK, I'm drawing process names, so check the process name against
  41.                 // my internal table of processes which are native
  42.                 MyAppInfo    *info = FindAppInfo(sp);
  43.  
  44.                 if ((info && (info->flags & kIsNative)) ||
  45.                         EqualString(sp, sysSoftStr, true, true))
  46.                 {
  47.                     Style    newFace = (info->flags & kIsNative) ? italic : 0;
  48.                     
  49.                     oldFace = aWind->port.txFace;
  50.                     resetFace = true;
  51.                     if (info->flags & kHas68K)
  52.                         newFace |= bold | condense;
  53.                     if (!newFace)                // 68K w/native code
  54.                         newFace = bold | condense;
  55.                     TextFace(newFace);
  56.                 }
  57.             }
  58.         }
  59.     }
  60.     
  61.     (glob->oldDrwStrTrap)(sp);
  62.     
  63.     if (resetFace)
  64.         aWind->port.txFace = oldFace;
  65.     
  66.     RestoreA4World(oldA4);
  67. }
  68.  
  69. MyAppInfo*    FindAppInfo(StringPtr sp)
  70. {
  71.     long        numEnt = GetHandleSize((Handle) glob->appInfo) / sizeof(MyAppInfo);
  72.     MyAppInfo    *info = *glob->appInfo;
  73.     
  74.     while (numEnt--)
  75.     {
  76.         Byte*    p = (Byte*) &sp[1];
  77.         Byte*    q = (Byte*) &info->appName[1];
  78.         Byte    l = sp[0];
  79.         
  80.         if (q[0] >= l)
  81.         {
  82.             if (sp[sp[0]] == (Byte) '…')
  83.                 --l;                // don't check the ellipsis
  84.             
  85.             while (l--)
  86.                 if (*p++ != *q++)
  87.                     break;
  88.             
  89.             if ((char) l < 0)        // strings match! (l is decremented one more time)
  90.                 return(info);
  91.         }
  92.         ++info;
  93.     }
  94.     
  95.     return(nil);
  96. }